//
//  WLRoutersCell.m
//  WanLian
//
//  Created by muzhuang on 2018/10/15.
//  Copyright © 2018年 wanlian. All rights reserved.
//

#import "WLRoutersCell.h"

@implementation WLRoutersCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _ivHead = [[UIImageView alloc] initWithFrame:CGRectMake(WLScaleX(16), (WLScaleX(64)-34)/2.0, 34, 34)];
        [self.contentView addSubview:_ivHead];
        
        _labTitle = [[UILabel alloc] initWithFrame:CGRectMake(WLScaleX(28)+34, WLScaleX(10), 150, 25)];
        _labTitle.font = [WLCommonTool fontTypePingFangSCMedium:17];
        _labTitle.textColor = wlBlackColor;
        [self.contentView addSubview:_labTitle];
        
        _labStatus = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_labTitle.frame)+WLScaleX(10), WLScaleX(10), 60, 25)];
        _labStatus.font = [WLCommonTool fontTypePingFangSCMedium:12];
        _labStatus.textColor = wlLightTextColor;
        [self.contentView addSubview:_labStatus];
        
        _labRouterID = [[UILabel alloc] init];//WithFrame:CGRectMake(CGRectGetMaxX(_labTitle.frame)+WLScaleX(10), WLScaleX(10), 60, 25)];
        _labRouterID.font = [WLCommonTool fontTypePingFangSCRegular:11];
        _labRouterID.textColor = wlLightTextColor;
        [self.contentView addSubview:_labRouterID];
        
        _labCurDevice = [[UILabel alloc] initWithFrame:CGRectMake(WIDTH_SCREEN_WL-70-WLScaleX(16), (WLScaleX(64)-34)/2.0-5, 70, 25)];//top==labtitle.top
        _labCurDevice.textAlignment = NSTextAlignmentCenter;
        _labCurDevice.font = [WLCommonTool fontTypePingFangSCRegular:12];
        _labCurDevice.textColor = wlblueColor;
        _labCurDevice.text = @"当前设备";
        [self.contentView addSubview:_labCurDevice];
        _labCurDevice.layer.cornerRadius = 5.0;
        _labCurDevice.layer.masksToBounds = YES;
        _labCurDevice.layer.borderWidth = 1;
        _labCurDevice.layer.borderColor = wlblueColor.CGColor;
        
        _btnChange = [[UIButton alloc] initWithFrame:_labCurDevice.frame];
        _btnChange.titleLabel.font = [WLCommonTool fontTypePingFangSCRegular:12];
        [_btnChange setTitleColor:wlDarkGrayColor forState:UIControlStateNormal];
        [_btnChange setTitle:@"切换设备" forState:UIControlStateNormal];
        [self.contentView addSubview:_btnChange];
        
//        _labCurDevice = [[UILabel alloc] initWithFrame:CGRectMake(WIDTH_SCREEN_WL-70-WLScaleX(16), (WLScaleX(64)-34)/2.0-5, 70, 25)];//top==labtitle.top
//        _labCurDevice.textAlignment = NSTextAlignmentCenter;
//        _labCurDevice.font = [WLCommonTool fontTypePingFangSCRegular:12];
//        _labCurDevice.textColor = wlDarkGrayColor;
//        _labCurDevice.text = @"当前设备";
//        [self.contentView addSubview:_labCurDevice];
//
//        _btnChange = [[UIButton alloc] initWithFrame:_labCurDevice.frame];
//        _btnChange.titleLabel.font = [WLCommonTool fontTypePingFangSCMedium:11];
//        [_btnChange setTitleColor:wlblueColor forState:UIControlStateNormal];
//        [_btnChange setTitle:@"切换设备" forState:UIControlStateNormal];
//        [self.contentView addSubview:_btnChange];
//        _btnChange.layer.cornerRadius = 5.0;
//        _btnChange.layer.masksToBounds = YES;
//        _btnChange.layer.borderWidth = 1;
//        _btnChange.layer.borderColor = wlblueColor.CGColor;
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    WLWkSelf
    [_labTitle mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.ivHead.mas_top).offset(-5);
        make.left.equalTo(weakSelf.ivHead.mas_right).offset(WLScaleX(12));
        make.height.equalTo(@(25));
    }];
    
    [_labStatus mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.labTitle.mas_top);
        make.left.equalTo(weakSelf.labTitle.mas_right).offset(WLScaleX(10));
        make.height.equalTo(@(25));
    }];
    
    [_labRouterID mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.labTitle.mas_bottom);
        make.left.equalTo(weakSelf.labTitle.mas_left);
        make.height.equalTo(@(20));
    }];
    
//    [_labTitle mas_remakeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(weakSelf.ivHead.mas_top).offset(-5);
//        make.left.equalTo(weakSelf.ivHead.mas_right).offset(WLScaleX(12));
//        make.height.equalTo(@(25));
//    }];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
